package com.aoyy.util;

import java.lang.reflect.Type;
import java.lang.reflect.ParameterizedType;
/**==========================================================================
 * <code>Generics</code> class is served as a <code>generic</code> utility 
 * @author Administrator
 * @date 2017-07-12
 * ========================================================================== */
public class Generics {
  public static Class<?> getGenericType(Class<?> clazz) {
	Type type = clazz.getGenericSuperclass();
	Type[] types = ((ParameterizedType)type).getActualTypeArguments();
	if (!(types[0] instanceof Class)) {
	  return Object.class;	
	}
	return (Class<?>)types[0];  
  }
  
  public static String getGenericName(Class<?> clazz) {
	return clazz.getSimpleName(); 
  }

}
